package com.example.springboot_19_quartz.service;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

@Component
public class TestService {
    private int count = 0;

    @Scheduled(cron="*/6 * * * * ?")
    public void foo()
    {

        System.out.println("foo() 定时执行("+count+")"+new Date());
    }

    private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");

    @Scheduled(fixedRate = 1000)
    public void reportCurrentTime() {
        System.out.println("现在时间：" + dateFormat.format(new Date()));
    }
}
